<?php

use think\migration\Migrator;
use think\migration\db\Column;

class CompanyImportOrder extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
        $table = $this->table('company_import_order', ['engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci','comment' => '公司导入订单表']);
        $table->addColumn('company_id', 'integer', ['default' => 0, 'limit' => 10, 'null' => false, 'comment' => '公司id'])
            ->addColumn('salesman_id', 'integer', ['default' => 0, 'limit' => 10, 'null' => false, 'comment' => '业务员id'])
            ->addColumn('salesman_name', 'string', ['default' => '', 'limit' => 50, 'null' => false, 'comment' => '业务员姓名'])
            ->addColumn('order_no', 'string', ['default' => '', 'limit' => 50, 'null' => false, 'comment' => '订单号'])
            ->addColumn('store_id', 'integer', ['default' => 0, 'limit' => 10, 'null' => false, 'comment' => '店铺id'])
            ->addColumn('store_name', 'string', ['default' => '', 'limit' => 50, 'null' => false, 'comment' => '店铺名称'])
            ->addColumn('goods_id','integer',['default'=>0,'limit'=>10,'null'=>false,'comment'=>'商品id'])
            ->addColumn('goods_name','string',['default'=>'','limit'=>50,'null'=>false,'comment'=>'商品名称'])
            ->addColumn('num','integer',['default'=>0,'limit'=>10,'null'=>false,'comment'=>'数量'])
            ->addColumn('unit','string', ['default' => '', 'limit' => 50, 'null' => false, 'comment' => '单位'])
            ->addColumn('max_money','decimal',['precision'=>10,'scale'=>2,'default'=>0.00,'null'=>false,'comment'=>'大单位金额'])
            ->addColumn('order_money', 'decimal', ['precision' => 10, 'scale' => 2, 'default' => 0.00, 'null' => false, 'comment' => '订单金额'])
            ->addColumn('remark', 'string', ['default' => '', 'limit' => 255, 'null' => false, 'comment' => '备注'])
            ->addColumn('order_time', 'integer', ['default' => null, 'limit' => 10, 'null' => false, 'comment' => '订单时间'])
            ->addColumn('create_time', 'integer', ['default' => null, 'limit' => 10, 'null' => false, 'comment' => '创建时间'])
            ->addColumn('update_time', 'integer', ['default' => null, 'limit' => 10, 'null' => false, 'comment' => '更新时间'])
            ->addIndex(['company_id','salesman_id','store_id','goods_id'], ['name' => 'idx_company_id_salesman_id_store_id_goods_id'])
            ->create();


    }
}
